package com.example.cash_register.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

@Slf4j
@ControllerAdvice
public class CashControllerAdvice {
    public CashControllerAdvice() {
        log.debug("controller.CashControllerAdvice()");
    }

    @ExceptionHandler(ErrRedirectException.class)
    public String logAndRedirect(ErrRedirectException e) {
        log.debug("{} : {}",e.getModule(),e.getError());
        return "redirect:" + e.getRedirectUrl();
    }
}
